package ServerData;

import java.util.concurrent.ConcurrentHashMap;

public class ServerUserData {
    //能够接受servrview传入的账号密码(Message包装)并匹配保持存的数据,
    // 根据结果输出消息类型
    ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
    public ServerUserData(){
        //添加测试集
        map.put("小明","123456");
        map.put("小红","xiaohong");
        map.put("小李","a123456");
    }

    public boolean checkUser(String name,String password){
        //该方法检查用户账密是否匹配
        if(!map.containsKey(name)){
            return false;
        }
        return map.get(name).equals(password);
    }
    public String getUser(){
        StringBuilder sb = new StringBuilder();
        for(String key:map.keySet()){
                sb.append(key).append("  ");
        }
        return sb.toString();
    }
}


















